function [ B ] = GetValidFieldsNoValues( A, color )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here

    % code searches for black
    A = color * A;
    

    % find all black stones
    [r,c] = find(A==1);
    
    % load zero B
    B = zeros(8);
    
    % search for all black stone in all directions
    max_index = length(r);
    for index = 1:1:max_index
        r_index = r(index);
        c_index = c(index);
        %------------------------------------------------------
        % search right
            % column is under 7 (search rigth, if black stone is max 
            % in column 6) && test if next field is white 
            if c_index<7 && (A(r_index,c_index+1)==-1)
                % yes: next stone is white
                column = c_index+2;
                % while row and column are valid and
                %   next field is white
                while column<8 && A(r_index,column)==-1
                    column = column+1;
                end
              	if A(r_index,column)==0 % test if next field is free
                    B(r_index,column) = 1; % -> valid field!!!

                end
            end
        %------------------------------------------------------
        % search left
            % column is over 2 (search left, if black stone is min 
            % in column 3) && test if next field is white 
            if c_index>2 && (A(r_index,c_index-1)==-1)
                % yes: next stone is white
                column = c_index-2;
                % while row and column are valid and
                %   next field is white
                while column>1 && A(r_index,column)==-1
                    column = column-1;
                end
              	if A(r_index,column)==0 % test if next field is free
                    B(r_index,column) = 1; % -> valid field!!!
                
                end
            end
        %------------------------------------------------------
        % search up
            % row is over 2(search up, if black stone is min 
            % in row 3) && test if next field is white 
            if r_index>2 && (A(r_index-1,c_index)==-1)
                % yes: next stone is white
                row = r_index-2;
                % while row and column are valid and
                %   next field is white
                while row>1 && A(row,c_index)==-1
                    row = row-1;
                end
              	if A(row,c_index)==0 % test if next field is free
                    B(row,c_index) = 1; % -> valid field!!!
             
                end
            end
        %------------------------------------------------------
        % search down
            % row is under 7 (search down, if black stone is max 
            % in row 6) && test if next field is white 
            if r_index<7 && (A(r_index+1,c_index)==-1)
                % yes: next stone is white
                row = r_index+2;
                % while row and column are valid and
                %   next field is white
                while row<8 && A(row,c_index)==-1
                    row = row+1;
                end
              	if A(row,c_index)==0 % test if next field is free
                    B(row,c_index) = 1; % -> valid field!!!
               
                end
            end
        %------------------------------------------------------
        % search right up
            % row is over 2 and column is under 7 (search right 
            % up, if black stone is min in row 3 and max in column 6)
            % && test if next field is white 
            if r_index>2 && c_index<7 && (A(r_index-1,c_index+1)==-1)
                % yes: next stone is white
                row = r_index-2;
                column = c_index+2;
                % while row and column are valid and
                %   next field is white
                while row>1 && column<8 && A(row,column)==-1
                    row = row-1;
                    column = column+1;
                end
              	if A(row,column)==0 % test if next field is free
                    B(row,column) = 1; % -> valid field!!!
                
                end
            end
        %------------------------------------------------------
        % search left down
            % row is under 7 and column is over 2 (search left 
            % down, if black stone is max in row 6 and min in column 3)
            % && test if next field is white 
            if r_index<7 && c_index>2 && A(r_index+1,c_index-1)==-1
                % yes: next stone is white
                row = r_index+2;
                column = c_index-2;
                % while row and column are valid and
                %   next field is white
                while row<8 && column>1 && A(row,column)==-1
                	row = row+1;
                	column = column-1;
                end
                if A(row,column)==0 % test if next field is free
                    B(row,column) = 1; % -> valid field!!!
                 
                end
            end
        %------------------------------------------------------
        % search left up
            % row is over 2 and column is over 2 (search left
            % up, if black stone is min in row 3 and min in column 3)
            % && test if next field is white 
            if r_index>2 && c_index>2 && A(r_index-1,c_index-1)==-1
                % yes: next stone is white
                row = r_index-2;
                column = c_index-2;
                % while row and column are valid and
                %   next field is white
                while row>1 && column>1 && A(row,column)==-1
                	row = row-1;
                	column = column-1;
                end
                if A(row,column)==0 % test if next field is free
                    B(row,column) = 1; % -> valid field!!!
        
                end
            end
        %------------------------------------------------------
        % search right down
            % row is under 7 and column is under 7 (search right
            % down, if black stone is max in row 6 and max in column 6)
            % && test if next field is white 
            if r_index<7 && c_index<7 && (A(r_index+1,c_index+1)==-1)
                % yes: next stone is white
                row = r_index+2;
                column = c_index+2;
                % while row and column are valid and
                %   next field is white
                while row<8 && column<8 && A(row,column)==-1 
                	row = row+1;
                	column = column+1;
                end
                if A(row,column)==0 % test if next field is free
                    B(row,column) = 1; % -> valid field!!!
              
                end
            end
        %------------------------------------------------------
    end
end

